<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="bankDetail.title"/></title>
    <meta name="menu" content="BankMenu"/>
    <meta name="heading" content="<fmt:message key='bankDetail.heading'/>"/>
</head>

<c:set var="delObject" scope="request"><fmt:message key="bankList.bank"/></c:set>
<script type="text/javascript">var msgDelConfirm =
   "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>

<section class="content-header">
    <h1>
        <fmt:message key="bankDetail.heading"/>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/loanRequests"><i class="fa fa-dashboard"></i><fmt:message key="bankDetail.heading"/></a></li>
        <li class="active"><fmt:message key="bankDetail.heading"/></li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title"><fmt:message key="bankDetail.heading"/></h3>
                </div>
                <div class="box-body">
                    <%@ include file="/common/messages.jsp" %>
                    <div class="row">
                    <div class="col-sm-12">
                        <form:errors path="*" cssClass="alert alert-danger alert-dismissable" element="div"/>
                        <form:form commandName="bank" method="post" action="bankform" cssClass="well form-horizontal margin"
                                   id="bankForm" onsubmit="return validateBank(this)">
                        <form:hidden path="id"/>
                            <form:hidden path="bankUser.id"/>
                            <form:hidden path="bankUser.version"/>
                        <div class="form-group">
                            <spring:bind path="bank.name">
                                <appfuse:label key="bank.name" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                            </spring:bind>
                                <form:input cssClass="form-control" path="name" id="name"  maxlength="255"/>
                                <form:errors path="name" cssClass="help-block"/>
                            </div>
                                <spring:bind path="bank.autoAudit">
                                <appfuse:label key="bank.autoAudit" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:checkbox path="autoAudit" id="autoAudit" />
                                    <form:errors path="autoAudit" cssClass="help-block"/>
                                </div>
                        </div>
                            <div class="form-group">
                                <spring:bind path="bank.bankUser.username">
                                <appfuse:label key="admin.username" path="bank.bankUser.username" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:input cssClass="form-control" path="bankUser.username" id="adminUser.username"  maxlength="255"/>
                                    <form:errors path="bankUser.username" cssClass="help-block"/>
                                </div>
                                <spring:bind path="bank.bankUser.password">
                                <appfuse:label key="user.password" path="bank.bankUser.password" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:password cssClass="form-control" path="bankUser.password" id="bankUser.password"  maxlength="255" showPassword="true"/>
                                    <form:errors path="bankUser.password" cssClass="help-block"/>
                                </div>
                                <spring:bind path="bank.bankUser.passwordHint">
                                <appfuse:label key="user.passwordHint" path="bank.bankUser.passwordHint" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:input cssClass="form-control" path="bankUser.passwordHint" id="adminUser.passwordHint"  maxlength="255"/>
                                    <form:errors path="bankUser.passwordHint" cssClass="help-block"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <spring:bind path="bank.bankUser.name">
                                <appfuse:label key="dealer.contactPerson" path="bank.bankUser.name" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:input cssClass="form-control" path="bankUser.name" id="adminUser.name"  maxlength="255"/>
                                    <form:errors path="bankUser.name" cssClass="help-block"/>
                                </div>
                                <spring:bind path="bank.bankUser.phoneNumber">
                                <appfuse:label key="dealer.contactNumber" path="bank.bankUser.phoneNumber" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:input cssClass="form-control" path="bankUser.phoneNumber" id="adminUser.phoneNumber"  maxlength="255"/>
                                    <form:errors path="bankUser.phoneNumber" cssClass="help-block"/>
                                </div>
                                <spring:bind path="bank.bankUser.email">
                                <appfuse:label key="user.email" path="bank.bankUser.email" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                    <form:input cssClass="form-control" path="bankUser.email" id="adminUser.email"  maxlength="255"/>
                                    <form:errors path="bankUser.email" cssClass="help-block"/>
                                </div>

                            </div>

                            <div class="form-group">
                                <spring:bind path="bank.billDate">
                                <appfuse:label key="bank.billDate" path="bank.billDate" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                    </spring:bind>
                                        <form:select cssClass="form-control" path="billDate" id="billDate">
                                            <form:options items="${availableDates}" itemValue="value"
                                                          itemLabel="label"/>
                                        </form:select>
                                    <form:errors path="billDate" cssClass="help-block"/>
                                </div>
                                <spring:bind path="bank.checkDate">
                                <appfuse:label key="bank.checkDate" path="bank.checkDate" styleClass="control-label col-sm-1"/>
                                <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                                </spring:bind>
                                    <form:select cssClass="form-control" path="checkDate" id="checkDate">
                                        <form:options items="${availableDates}" itemValue="value"
                                                      itemLabel="label"/>
                                    </form:select>
                                    <form:errors path="checkDate" cssClass="help-block"/>
                                </div>

                            </div>

                            <div class="form-group">
                                <button type="submit" class="btn btn-primary" id="save" name="save" onclick="bCancel=false">
                                    <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
                                </button>
                                <c:if test="${not empty bank.id}">
                                    <button type="submit" class="btn btn-danger" id="delete" name="delete" onclick="bCancel=true;return confirmMessage(msgDelConfirm)">
                                        <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                                    </button>
                                </c:if>

                                <button type="submit" class="btn btn-default" id="cancel" name="cancel" onclick="bCancel=true">
                                    <i class="icon-remove"></i> <fmt:message key="button.cancel"/>
                                </button>
                            </div>
                        </form:form>
                    </div>
                    </div>
<c:if test="${not empty bank.id}">
                    <div class="row">
                        <div class="col-sm-12">
                            <display:table name="loanProductList" class="table table-bordered table-hover" requestURI="" id="loanProductList" export="false" pagesize="25">
                                <display:column property="productName" sortable="true" href="loanProductform?from=bank" media="html"
                                                paramId="id" paramProperty="id" titleKey="loanProduct.productName"/>
                                <display:column property="id" media="csv excel xml pdf" titleKey="loanProduct.id"/>
                                <display:column property="bank.name" sortable="true" titleKey="loanProduct.bank"/>
                                <display:column property="coef" sortable="true" titleKey="loanProduct.coef"/>
                                <display:column property="crLL" sortable="true" titleKey="loanProduct.crLL"/>
                                <display:column property="crUL" sortable="true" titleKey="loanProduct.crUL"/>
                                <display:column property="dpLL" sortable="true" titleKey="loanProduct.dpLL"/>
                                <display:column property="dpUL" sortable="true" titleKey="loanProduct.dpUL"/>
                                <display:column property="faLL" sortable="true" titleKey="loanProduct.faLL"/>
                                <display:column property="faUL" sortable="true" titleKey="loanProduct.faUL"/>
                                <display:column sortable="true" titleKey="loanProduct.loanYears">
                                    <c:forEach var="year" items="${loanProductList.loanYears}" varStatus="status">
                                        <fmt:message key="LOAN_YEARS_${year}"/><c:if test="${!status.last}">,</c:if>
                                    </c:forEach>
                                </display:column>
                                <display:column sortable="true" titleKey="loanProduct.enabled">
                                    <input type="checkbox" disabled="disabled" <c:if test="${loanProductList.enabled}">checked="checked"</c:if>/>
                                </display:column>

                                <display:setProperty name="paging.banner.item_name"><fmt:message key="loanProductList.loanProduct"/></display:setProperty>
                                <display:setProperty name="paging.banner.items_name"><fmt:message key="loanProductList.loanProducts"/></display:setProperty>

                                <display:setProperty name="export.excel.filename"><fmt:message key="loanProductList.title"/>.xls</display:setProperty>
                                <display:setProperty name="export.csv.filename"><fmt:message key="loanProductList.title"/>.csv</display:setProperty>
                                <display:setProperty name="export.pdf.filename"><fmt:message key="loanProductList.title"/>.pdf</display:setProperty>
                            </display:table>
                            <div id="actions" class="btn-group margin">
                                <a href='<c:url value="/loanProductform?bankId=${bank.id}"/>' class="btn btn-primary">
                                    <i class="fa fa-plus"></i> <fmt:message key="button.add"/></a>
                            </div>
                        </div>
                    </div>
</c:if>
                </div>
            </div>
        </div>
    </div>

</section>

<v:javascript formName="bank" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value='/scripts/validator.jsp'/>"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['bankForm']).focus();

        $('.datepicker').datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: "mm/dd/yy"
        });
    });
</script>
